using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Archives Test Class
  /// </summary>
  [TestClass]
  public class TestArchives
  {
    #region Class Variables
    private CdoPrms<DOArchives>		m_Archives;
    private CdoPrmsList<DOArchives>	m_AllArchives;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestArchives()
    {
      // Create the data objects
      this.m_Archives	= new CdoPrms<DOArchives>();
      this.m_AllArchives	= new CdoPrmsList<DOArchives>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Archives data objects
    /// </summary>
    [TestMethod]
    public void ArchivesRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllArchives.DataObject = new DOArchives();
      this.m_AllArchives.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllArchives.PerformAction())
      {
        // Assert the errors
        if (this.m_AllArchives.Errors.Count > 0) { Assert.Fail(this.m_AllArchives.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Archives
    /// </summary>
    [TestMethod]
    public void ArchivesCreate()
    {
      // Set up the data object for creation
      this.m_Archives.DataObject.CreatedByUserId = 12.3F;
      this.m_Archives.DataObject.ArchiveDate = DateTime.Now;
      this.m_Archives.DataObject.ArchiveStatus = "Test ArchiveStatus";
      this.m_Archives.DataObject.DivisionName = "Test DivisionName";
      this.m_Archives.DataObject.DepartmentName = "Test DepartmentName";
      this.m_Archives.DataObject.AttachedFile = new byte[] { 1, 2, 3 };
      this.m_Archives.DataObject.Comments = "Test Comments";
      this.m_Archives.DataObject.DestructionDate = DateTime.Now;
      this.m_Archives.DataObject.Shred = false;
      this.m_Archives.DataObject.NoShredReason = "Test NoShredReason";
      this.m_Archives.DataObject.CurrentLocation = "Test CurrentLocation";
      this.m_Archives.DataObject.DeliveryCollection = "Test DeliveryCollection";
      this.m_Archives.DataObject.DueDate = DateTime.Now;
      this.m_Archives.DataObject.ApprovedUserId = 12.3F;
      this.m_Archives.DataObject.ApprovedDate = DateTime.Now;
      this.m_Archives.DataObject.ReceivedbyUserId = 12.3F;
      this.m_Archives.DataObject.ReceivedDate = DateTime.Now;
      this.m_Archives.DataObject.ClosedByUserId = 12.3F;
      this.m_Archives.DataObject.ClosedDate = DateTime.Now;
      this.m_Archives.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Archives.PerformAction())
      {
        // Assert the errors
        if (this.m_Archives.Errors.Count > 0) { Assert.Fail(this.m_Archives.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Archives
    /// </summary>
    [TestMethod]
    public void ArchivesRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Archives.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Archives.DataObject.ArchiveId = 10;
      }

      // Set up the data object action for retrieval
      this.m_Archives.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Archives.PerformAction())
      {
        // Assert the errors
        if (this.m_Archives.Errors.Count > 0) { Assert.Fail(this.m_Archives.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
